package com.skiving.cloud.admin.service.impl;

import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.solon.service.impl.ServiceImpl;
import com.skiving.cloud.common.utils.PageParameter;
import com.skiving.cloud.admin.entity.SysDashboardSetting;
import com.skiving.cloud.admin.mapper.SysDashboardSettingMapper;
import com.skiving.cloud.admin.service.SysDashboardSettingService;
import org.noear.solon.annotation.Component;
import org.noear.solon.Utils;

/**
 * 首页看板设置 服务层实现。
 *
 * @author skivingcloud
 * @since 2025-03-08
 */
@Component
public class SysDashboardSettingServiceImpl extends ServiceImpl<SysDashboardSettingMapper, SysDashboardSetting>  implements SysDashboardSettingService {
    /**
     * 分页查询首页看板设置
     *
     * @param parameter 查询参数
     * @return 分页查询结果
     */
    @Override
    public Page<SysDashboardSetting> queryByPage(PageParameter<SysDashboardSetting> parameter){
        Page<SysDashboardSetting> page = new Page<>(parameter.getPage(), parameter.getPageSize());
        QueryWrapper queryWrapper = QueryWrapper.create();
        if (parameter.getParam() != null) {
            //查询条件
            if (Utils.isNotBlank(parameter.getParam().getId())) {
                queryWrapper.and(SysDashboardSetting::getId).like(parameter.getParam().getId());
            }
            if (Utils.isNotBlank(parameter.getParam().getType())) {
                queryWrapper.and(SysDashboardSetting::getType).like(parameter.getParam().getType());
            }
            if (Utils.isNotBlank(parameter.getParam().getDashboardId())) {
                queryWrapper.and(SysDashboardSetting::getDashboardId).like(parameter.getParam().getDashboardId());
            }
            if (Utils.isNotBlank(parameter.getParam().getTypeId())) {
                queryWrapper.and(SysDashboardSetting::getTypeId).like(parameter.getParam().getTypeId());
            }
            if (Utils.isNotBlank(parameter.getParam().getCreateUser())) {
                queryWrapper.and(SysDashboardSetting::getCreateUser).like(parameter.getParam().getCreateUser());
            }
            if (Utils.isNotBlank(parameter.getParam().getModUser())) {
                queryWrapper.and(SysDashboardSetting::getModUser).like(parameter.getParam().getModUser());
            }
            if (Utils.isNotBlank(parameter.getParam().getTenantId())) {
                queryWrapper.and(SysDashboardSetting::getTenantId).like(parameter.getParam().getTenantId());
            }
        }
        return this.page(page, queryWrapper);
    }
}
